In encoding of a video signal, it is necessary to perform the encoding so that a decoder does not fail. In an H.264 encoding scheme, a hypothetical decoder, a hypothetical reference decoder (HRD), obtained by modeling a decoder is defined. An H.264 encoder need perform encoding so that the hypothetical decoder does not fail. The present invention is technology for reducing deterioration in image quality while suppressing the failure of a CPB of a hypothetical decoder, specifically, underflow of the CPB.
In FIG. 1, a conceptual diagram of the underflow of the CPB is illustrated. In the case of a constant bit rate, an encoded stream is input to the CPB at that bit rate (reference symbol RS1 in FIG. 1). The data amount of encoded streams in the CPB in each time is referred to as a “residual bit rate”. The hypothetical decoder extracts the encoded stream corresponding to each picture from the CPB. In this case, the CPB residual bit rate is instantly reduced by the bit rate corresponding to each picture. FIG. 1 illustrates an exemplary case of the constant bit rate, but the same applies to a case of a variable bit rate.
The CPB underflow refers to a situation in which an encoded stream of a picture is insufficient in the CPB when the hypothetical decoder attempts to extract the encoded stream of the picture from the CPB, as illustrated in FIG. 1. In H.264-based encoding, the state of the CPB need be verified while encoding is being performed to produce a stream that does not cause the CPB underflow. As described above, the CPB of the hypothetical decoder is standardized in H.264 and further details are described, for example, in Non-Patent Document 1 described later.
It is to be noted that the same concept as the CPB is also defined in other encoding standards. For example, in Moving Picture Experts Group (MPEG)-2, there is a video buffering verifier (VBV), and a buffer model of such a decoder is herein referred to as “a hypothetical buffer”. In the following description, a “CPB” can be read as the words “hypothetical buffer” for interpretation in a broad sense.
Methods for encoding a video signal include 1-pass encoding technology and multi-pass encoding technology. In the 1-pass encoding, generally, pictures of an input video are sequentially encoded. In contrast, in the multi-pass encoding, an input video is encoded a plurality of times. In 2-pass encoding, second encoding is performed using a result of first encoding. In the following description, the conventional art of the 1-pass encoding is referred to as “conventional art a” and the conventional art of the 2-pass encoding is referred to as “conventional art b”.
<Conventional Art a>
In the 1-pass encoding, since input pictures are sequentially encoded, the nature of a future picture after an encoding target picture is not known. Therefore, the degree of complexity of the future picture is estimated, for example, from the generated bit rate of a picture encoded in the past to suppress CPB underflow. For example, in the technology of Patent Document 1, prior to encoding of each picture, the degree of complexity of a video obtained from a result of encoding in the past is determined as an estimated value of the degree of complexity of the remaining videos of a group of pictures (GOP). Under the premise of the estimated value of the degree of complexity, a quantization parameter generating the maximum bit rate that is available to encoding of the remaining videos of the GOP is estimated from the residual bit rate of the CPB, and it is used as a lower limit value of a quantization parameter in encoding of the encoding target picture, thereby suppressing CPB underflow. For this reason, in the case of a transition from a simple scene to a complex scene, in encoding of the simple scene, a bit rate is generated assuming that the bit rate is the same even in the future, and in encoding of the complex scene, the CPB does not have a residual bit rate that is required to maintain the image quality and a large quantization parameter is used. As a result, there is a problem in that the image quality is greatly deteriorated.
<Conventional Art b>
In 2-pass encoding, all pictures of an input video are encoded, and the bit rate of each picture generated at this time is used for second encoding. In this method, since the complexity of each portion of the video is known at the time of the second encoding, unlike the case of the 1-pass encoding, the CPB underflow is expected to be suppressed with deterioration in image quality being suppressed. For example, in the technology of Patent Document 2, in first encoding, the degree of complexity of each frame is obtained and an allocation bit rate of each frame is obtained. A check is made as to whether or not this allocation bit rate results in the CPB underflow. If the CPB underflow occurs, the allocation bit rate is modified. In this way, since the degree of complexity of each frame is known, the image quality can be expected to be maintained while the CPB underflow is suppressed. However, in this method, since all frames of the input video are twice encoded, there is a problem in that a large calculation amount is required.